1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.google.common.collect;
18
19 import com.google.common.annotations.GwtCompatible;
20 import com.google.common.annotations.GwtIncompatible;
21
22 import java.io.InvalidObjectException;
23 import java.io.ObjectInputStream;
24 import java.io.Serializable;
25
26
27
28
29
30
31
32
33 @GwtCompatible(serializable = true, emulated = true)
34 @SuppressWarnings("serial")
35 abstract class ImmutableAsList<E> extends ImmutableList<E> {
36 abstract ImmutableCollection<E> delegateCollection();
37
38 @Override public boolean contains(Object target) {
39
40
41 return delegateCollection().contains(target);
42 }
43
44 @Override
45 public int size() {
46 return delegateCollection().size();
47 }
48
49 @Override
50 public boolean isEmpty() {
51 return delegateCollection().isEmpty();
52 }
53
54 @Override
55 boolean isPartialView() {
56 return delegateCollection().isPartialView();
57 }
58
59
60
61
62 @GwtIncompatible("serialization")
63 static class SerializedForm implements Serializable {
64 final ImmutableCollection<?> collection;
65 SerializedForm(ImmutableCollection<?> collection) {
66 this.collection = collection;
67 }
68 Object readResolve() {
69 return collection.asList();
70 }
71 private static final long serialVersionUID = 0;
72 }
73
74 @GwtIncompatible("serialization")
75 private void readObject(ObjectInputStream stream)
76 throws InvalidObjectException {
77 throw new InvalidObjectException("Use SerializedForm");
78 }
79
80 @GwtIncompatible("serialization")
81 @Override Object writeReplace() {
82 return new SerializedForm(delegateCollection());
83 }
84 }